cmake_minimum_required(VERSION 3.22)
project(ir_camera_driver)

set(CMAKE_CXX_STANDARD 17)
set(MAKE_CXX_STANDARD_REQUIRED True)

# set(CMAKE_BUILD_TYPE Release)
# set(CMAKE_CXX_FLAGS_RELEASE "-O3")
set(CMAKE_BUILD_TYPE Debug)

# you may need these 2 lines, and set your own paths
set(PYTHON_EXECUTABLE "/home/cwb/software/miniconda3/envs/hikvision/bin/python")
set(PYTHON_INCLUDE_DIRECTORY "/home/cwb/software/miniconda3/envs/hikvision/include/python3.10")

add_subdirectory(extern/pybind11)

add_executable(camera_test 
                camera_test.cpp 
                hk_simple_camera.cpp 
                hk_camera.cpp)

target_include_directories(camera_test PRIVATE 
                ${CMAKE_SOURCE_DIR}/extern/hikvision_sdk/include 
                )

target_link_libraries(camera_test PRIVATE
                ${CMAKE_SOURCE_DIR}/extern/hikvision_sdk/lib/libhcnetsdk.so
                )

pybind11_add_module(simple_camera 
                    bind.cpp 
                    hk_simple_camera.cpp 
                    hk_camera.cpp)

# 添加:包含路径 or 库路径
target_include_directories(simple_camera PRIVATE 
                        ${CMAKE_SOURCE_DIR}/extern/hikvision_sdk/include 
                        )

find_package(Python3 COMPONENTS Interpreter Development)

if(Python3_FOUND)
    target_link_libraries(simple_camera PRIVATE Python3::Python)
endif()
                        
target_link_libraries(simple_camera PRIVATE
                        ${CMAKE_SOURCE_DIR}/extern/hikvision_sdk/lib/libhcnetsdk.so
                        )


set(CMAKE_INSTALL_PREFIX ${CMAKE_SOURCE_DIR}/../output)

# 安装库和头文件
install(TARGETS simple_camera
    LIBRARY DESTINATION lib
    )

install(FILES ${CMAKE_SOURCE_DIR}/HCNetSDK.h 
            ${CMAKE_SOURCE_DIR}/hk_camera.h 
            ${CMAKE_SOURCE_DIR}/hk_simple_camera.h DESTINATION include
            )